package com.naja.auth2server.common.dto;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import java.io.Serializable;
import java.util.List;

/**
 * 分页结果
 */
@Getter
@Setter
@ToString
@ApiModel("接口分页数据结构")
@AllArgsConstructor
@NoArgsConstructor
public class PageResult<T> extends BasePageReqDto implements Serializable {

    @ApiModelProperty("总条数")
    private Long total;

    @ApiModelProperty("数据")
    private List<T> records;

    public PageResult(Page<T> page) {
        super.setPageNum(Long.valueOf(page.getCurrent()).intValue());
        super.setPageSize(Long.valueOf(page.getSize()).intValue());
        this.total = page.getTotal();
        this.records = page.getRecords();
    }
}
